<?php

namespace Org\Alidayu;

include("TopSdk.php");

use TopClient;
use AlibabaAliqinFcSmsNumSendRequest;

/** 返回的结果
{
 	"alibaba_aliqin_fc_sms_num_send_response":{
 		"result":{
 			"err_code":"0", // 错误码
 			"model":"106901828073^1109327594373",
 			"success":true // false 成功， FALSE失败
 		},
 		"request_id":"2gi6cm2sdjt2"
 	}
}
 
 */


class AlidayuSendSms{
	protected $appkey; // 注册后获取
	protected $secret; // 注册后获取
	protected $extend = ""; //去查手册
	protected $smsType = "normal";
	protected $smsFreeSignName = "phper小范";
	protected $smsTemplateCode = "SMS_61320031"; // 短信的模板
	protected $recNum; // 接受短信的号码


	public function __construct()
	{
		$sendArray = C("SMS_CONFIG");
		$this->check($SendArray);
	}
  
  	public function send()
  	{
  		$c = new TopClient;
		$c ->appkey = $this->appkey ;
		$c ->secretKey = $this->secret ;
		$req = new AlibabaAliqinFcSmsNumSendRequest;
		$req ->setExtend( $this->extend );
		$req ->setSmsType( $this->smsType );
		$req ->setSmsFreeSignName( $this->smsFreeSignName );
		$req ->setSmsParam( "" ); // json格式的数组
		$req ->setRecNum( $this->recNum );
		$req ->setSmsTemplateCode( $this->smsTemplateCode );
		$resp = $c ->execute( $req );

		return $resp;
  	}


  	/**
  	 * 验证各成员属性的值
  	 * @AuthorHTL
  	 * @DateTime  2017-04-12T10:59:48+0800
  	 * @param     [type]                   $sendArray [description]
  	 * @return    [type]                              [description]
  	 */
  	public function check($sendArray)
  	{
  		if (!is_array($sendArray) && empty($sendArray)) {
  			return "false";
  		}
  	}
 
}
